gesture: Add GTK_PHASE_TARGET
authorCarlos Garnacho <carlosg@gnome.org>
Sat, 10 May 2014 18:50:23 +0000 (20:50 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 23 May 2014 17:54:30 +0000 (19:54 +0200)
This phase is meant to run in the default widget handlers, as opposed
to externally as in the bubble/capture phase. This will be most usually
the expected phase for every controller replacing code in event handlers
in GTK+, just so invocation and triggering order is kept unaltered.

gtk/gtkenums.h
gtk/gtkgesture.c
gtk/gtkwidget.c

index c2076f5167a2318262528444481994f91bb0d11a..d0954507849797fcf9795a4fa3d8902aae4f208a 100644 (file)
@@ -1060,8 +1060,11 @@ typedef enum
  *   to the event widget. This option should only be used on containers that
  *   might possibly handle events before their children do.
  * @GTK_PHASE_BUBBLE: Events are delivered in the bubble phase. The bubble
- *   phase happens after the capture phase, runs from the event widget, up to
- *   the toplevel.
+ *   phase happens after the capture phase, and before the default handlers
+ *   are run. This phase runs from the event widget, up to the toplevel.
+ * @GTK_PHASE_TARGET: Events are delivered in the default widget event handlers,
+ *   note that widget implementations must chain up on button, motion, touch and
+ *   grab broken handlers for controllers in this phase to be run.
  *
  * Describes the stage at which events are fed into a #GtkEventController.
  *
@@ -1071,7 +1074,8 @@ typedef enum
 {
   GTK_PHASE_NONE,
   GTK_PHASE_CAPTURE,
-  GTK_PHASE_BUBBLE
+  GTK_PHASE_BUBBLE,
+  GTK_PHASE_TARGET
 } GtkPropagationPhase;
 
 /**
index 9689f55a54dacc10a7204085f8425101d3907ab1..5cdba14d0ec4a64a5405f30a4a58a3e1c109a0c8 100644 (file)
@@ -1530,7 +1530,7 @@ gtk_gesture_attach (GtkGesture          *gesture,
   GtkWidget *widget;
 
   g_return_if_fail (GTK_IS_GESTURE (gesture));
-  g_return_if_fail (phase >= GTK_PHASE_NONE && phase <= GTK_PHASE_BUBBLE);
+  g_return_if_fail (phase >= GTK_PHASE_NONE && phase <= GTK_PHASE_TARGET);
 
   widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
   _gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture), phase);
index 1023cd1104d5dafc1ca4bfe2ff2e35e650720dea..62e43bbd0e9f9fe5493eaf66fb327f584cf33d1a 100644 (file)
@@ -16700,8 +16700,7 @@ event_controller_grab_notify (GtkWidget           *widget,
   if (!grab_widget || grab_widget == widget)
     return;
 
-  if (((data->phase == GTK_PHASE_NONE ||
-        data->phase == GTK_PHASE_BUBBLE) &&
+  if ((data->phase != GTK_PHASE_CAPTURE &&
        !gtk_widget_is_ancestor (widget, grab_widget)) ||
       (data->phase == GTK_PHASE_CAPTURE &&
        !gtk_widget_is_ancestor (widget, grab_widget) &&
@@ -16802,7 +16801,7 @@ _gtk_widget_add_controller (GtkWidget           *widget,
   g_return_if_fail (GTK_IS_EVENT_CONTROLLER (controller));
   g_return_if_fail (widget == gtk_event_controller_get_widget (controller));
   g_return_if_fail (!_gtk_widget_has_controller (widget, controller));
-  g_return_if_fail (phase >= GTK_PHASE_NONE && phase <= GTK_PHASE_BUBBLE);
+  g_return_if_fail (phase >= GTK_PHASE_NONE && phase <= GTK_PHASE_TARGET);
 
   priv = widget->priv;
   data = _gtk_widget_has_controller (widget, controller);